﻿using System.IO;
using System.Web;

namespace ZSoftInstagram.Services.Upload
{
    public class UploadService
    {
        IUploadDirectoryProvider _pathProvider;
        
        public UploadService(IUploadDirectoryProvider provider)
        {
            this._pathProvider = provider;
        }

        public string Upload(HttpPostedFileBase file)
        {
            var virtualPath = Path.Combine(this._pathProvider.ProvidePath(), file.FileName);
            var physicalPath = HttpContext.Current.Server.MapPath(virtualPath);

            file.SaveAs(physicalPath);
            return virtualPath;
        }
    }
}
